Public Class FormUtil

    Public Enum eDocType
        HTML401Transitional
        HTML401Strict
        XHTML10Transitional
        XHTML10Strict
    End Enum

    Public Shared Sub SelectItem(ByVal ddl As DropDownList, ByVal value As String)
        For Each oItem As ListItem In ddl.Items
            If oItem.Value = value Then
                oItem.Selected = True
                Exit For
            End If
        Next
    End Sub

    Public Shared Function AppPath(ByVal ThePage As Page) As String
        Dim sRet As String = ThePage.Request.ApplicationPath

        If sRet.EndsWith("/") = False Then sRet &= "/"
        Return sRet
    End Function

    Public Shared Function GetDocType(ByVal Type As eDocType) As String
        Select Case Type
            Case eDocType.HTML401Strict
                Return "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01//EN"" ""http://www.w3.org/TR/html4/strict.dtd"">"
            Case eDocType.HTML401Transitional
                Return "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd"">"
            Case eDocType.XHTML10Strict
                Return "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">"
            Case eDocType.XHTML10Transitional
                Return "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
        End Select
    End Function

    Public Shared Function GetHtmlNamespace(ByVal Type As eDocType) As String
        Select Case Type
            Case eDocType.HTML401Strict
                Return ""
            Case eDocType.HTML401Transitional
                Return ""
            Case eDocType.XHTML10Strict, eDocType.XHTML10Transitional
                Return " xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"""
        End Select
    End Function

End Class
